package com.abhinav.spring.config;

import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;

import com.abhinav.spring.bean.HelloWorld;
import com.abhinav.spring.bean.PrototypeBean;
import com.abhinav.spring.bean.SingletonBean;

@Configuration
public class AppConfig {
	
	@Bean(autowire=Autowire.BY_TYPE, name="helloBean") 
	@Qualifier("helloBean1")
	public HelloWorld getHelloWorldBean(){
		HelloWorld hello = new HelloWorld();
		hello.setName("Abhinav");
		
		return hello;
	}
	

	@Bean(autowire=Autowire.BY_TYPE, name="newHelloBean") 
	@Qualifier("helloBean2")
	public HelloWorld getHelloWorldBean2(){
		HelloWorld hello = new HelloWorld();
		hello.setName("Abhishek");
		
		return hello;
	}
	
	@Bean(name="singletonBean", autowire=Autowire.BY_TYPE)
	@Scope("singleton")
	public SingletonBean singletonBean(){
		return new SingletonBean();
	}
	
	@Bean(name="prototypeBean", autowire=Autowire.BY_TYPE)
	@Scope(value="prototype", proxyMode=ScopedProxyMode.TARGET_CLASS)
	public PrototypeBean prototypeBean(){
		return new PrototypeBean();
	}

}
